package com.example.smartwaterapi.common.api;

/**
 * API响应码枚举类
 */
public enum ResultCode implements IErrorCode {
    SUCCESS(200, "操作成功"),
    FAILED(500, "操作失败"),
    VALIDATE_FAILED(400, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    FORBIDDEN(403, "没有相关权限"),
    
    // 微信相关错误码
    WECHAT_LOGIN_FAILED(50001, "微信登录失败"),
    WECHAT_CODE_INVALID(50002, "微信授权码无效"),
    WECHAT_USER_DENY(50003, "用户拒绝授权"),
    WECHAT_CODE_USED(50004, "微信授权码已被使用"),
    
    // 用户相关错误码
    USER_NOT_FOUND(50101, "用户不存在"),
    USER_PASSWORD_ERROR(50102, "密码错误"),
    USER_LOCKED(50103, "账户已被锁定"),
    USER_EXISTS(50104, "用户已存在"),
    USER_PHONE_EXISTS(50105, "手机号已注册"),
    
    // 设备相关错误码
    DEVICE_NOT_FOUND(50201, "设备不存在"),
    DEVICE_BIND_FAILED(50202, "设备绑定失败"),
    DEVICE_UNBIND_FAILED(50203, "设备解绑失败"),
    DEVICE_ALREADY_BOUND(50204, "设备已被绑定"),
    
    // 数据相关错误码
    DATA_NOT_FOUND(50301, "数据不存在"),
    DATA_CREATE_FAILED(50302, "数据创建失败"),
    DATA_UPDATE_FAILED(50303, "数据更新失败"),
    
    // 系统相关错误码
    SYSTEM_ERROR(50501, "系统内部错误"),
    API_LIMIT_REACHED(50502, "接口访问频率超限"),
    API_NOT_FOUND(50503, "接口不存在"),
    API_DISABLED(50504, "接口已被禁用");
    
    private long code;
    private String message;

    private ResultCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public long getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
} 